import App from './App'

// 样式初始化
import '@/assets/css/reset.scss'
import '@/assets/css/minx.less'
import '@/assets/css/kComponent.scss'

// 引入字体图标
import '@/assets/iconfont/common/iconfont.css'
import '@/assets/iconfont/common/iconfont.js'
import '@/assets/iconfont/lowcodeStyle/iconfont.css'
import '@/assets/iconfont/lowcodeStyle/iconfont.js'

/* 引入Element Plus */
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import '@/assets/css/element-variables.scss'
// import * as ElementPlusIconsVue from '@element-plus/icons-vue'

// 微信小程序
// #ifdef MP-WEIXIN
import "@/wxcomponents/vant-weapp/common/index.wxss"
// #endif

// 微信小程序
// #ifndef MP-WEIXIN
import Vant from 'vant';
import 'vant/lib/index.css';
// #endif


// 全局过滤器
import globalFilter from '@/utils/filter'

import store from '@/store/index.js'

import * as Pinia from 'pinia';
import Vuex from "vuex";
import {
	createSSRApp
} from 'vue'

export function createApp() {
	const app = createSSRApp(App)
	app.use(store)
	app.use(Pinia.createPinia());
	app.use(ElementPlus)
	app.use(Vant)
	
	// 注册wdnoticestyle所有组件,因为component动态组件不支持easycom注册
	const modules = import.meta.glob('./widgets_set/Wd**/**.vue', {
		eager: true
	});
	// console.info(Object.entries(modules))
	Object.entries(modules).forEach(([path, definition]) => {
		const componentName = definition.default.name;
		app.component(componentName, definition.default);
	});

	//element plus icon组件
	for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
		app.component(key, component)
	}
	return {
		app,
		Vuex,
		Pinia
	}
}